//
//  ATLTabBarController.m
//  ATLife
//
//  Created by 曹阳 on 16/9/26.
//  Copyright © 2016年 曹阳. All rights reserved.
//

#import "ATLTabBarController.h"
#import "ATLNavigationController.h"
#import "ObjcController.h"

@implementation ATLTabBarController

+ (void)initialize
{
    // 通过appearance统一设置所有UITabBarItem的文字属性
    // 后面带有UI_APPEARANCE_SELECTOR的方法, 都可以通过appearance对象来统一设置
    
    // 1.正常状态的文字属性设置
    NSMutableDictionary *attributesNormal = [NSMutableDictionary dictionary];
    attributesNormal[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    attributesNormal[NSForegroundColorAttributeName] = [UIColor grayColor];
    
    // 2.选中状态的文字属性设置
    NSMutableDictionary *attributesSelected = [NSMutableDictionary dictionary];
    attributesSelected[NSFontAttributeName] = attributesNormal[NSFontAttributeName];
    attributesSelected[NSForegroundColorAttributeName] = [UIColor orangeColor];
    
    UITabBarItem *item = [UITabBarItem appearance];
    [item setTitleTextAttributes:attributesNormal forState:UIControlStateNormal];
    [item setTitleTextAttributes:attributesSelected forState:UIControlStateSelected];
    
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
}
    
/**
 * 初始化子控制器
 */
- (void)setupChildViewController:(UIViewController *)vc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage
{
    // 设置文字和图片
    vc.tabBarItem.title = title;
    vc.tabBarItem.image = [UIImage imageNamed:image];
    vc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];;
    
    ATLNavigationController *nav = [[ATLNavigationController alloc] initWithRootViewController:vc];
    [self addChildViewController:nav];
}

@end
